/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package riteservices.services;

import java.util.List;
import riteservices.model.bean.Route;
import riteservices.model.dao.RouteDAO;
import riteservices.util.Constantes;

/**
 *
 * @author sixviv
 */
public class RouteSrv {
    private RouteDAO routeDAO = new RouteDAO();

    public String createRoute(Route route){
        if(routeDAO.add(route)){
            return Constantes.TRUE_STR;
        }else{
            return Constantes.FALSE_STR;
        }
    }

    public String updateRoute(Route route){
        if(routeDAO.update(route)){
        return Constantes.TRUE_STR;
        }else{
        return Constantes.FALSE_STR;
        }
    }

    public String deleteRoute(Route route){
    if(routeDAO.delete(route)){
        return Constantes.TRUE_STR;
        }else{
        return Constantes.FALSE_STR;
        }
    }

    public Route getRouteDetails(long routeid){
    return routeDAO.getRouteById(routeid);
    }
    
    public List<Route> searchByOrigin(String term)
    {
        return routeDAO.getRoutesByOrigin(term);
    }
    
    public List<Route> searchByDestiny(String term)
    {
        return routeDAO.getRoutesByDestiny(term);
    }

}
